package com.taimanetworks.kafka.parseTsp;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;


public class StructureBeanUtil {
    public static Sourcedata getSource(String message) throws Exception {
        JSONObject data = JSON.parseObject(message);

        System.out.println("开始处理数据。。。");
        Sourcedata sourcedata = new Sourcedata();

        if ((message != null) || (!message.equals(""))) {


            //vin
            String vin = data.getString("vin") != null ? data.getString("vin") : "";
            sourcedata.setVin(vin.toString());
            //gpss_time
            String gatherTime = data.getString("gatherTime") != null ? data.getString("gatherTime") : "";
            sourcedata.setGpss_time(gatherTime);
            //报文类型
            String gpss_type = data.getString("command") != null ? data.getString("command") : "";
            sourcedata.setGpss_type(gpss_type);


            String car_statue ="";
            String recharge_statue ="";
            String run_statue ="";
            String vehspeed ="";
            String milleage ="";
            String total_voltage ="";
            String total_current ="";
            String soc ="";
            String dc_statue ="";
            String gears ="";
            String insulation_resistance ="";
            String accele_pedal ="";
            String brake_paddle ="";
            if (data.getJSONObject("zhengCheShuJu") != null) {
                car_statue = data.getJSONObject("zhengCheShuJu").getString("car_statue") != null ? data.getJSONObject("zhengCheShuJu").getString("car_statue") : "";
                recharge_statue = data.getJSONObject("zhengCheShuJu").getString("recharge_statue") != null ? data.getJSONObject("zhengCheShuJu").getString("recharge_statue") : "";
                run_statue = data.getJSONObject("zhengCheShuJu").getString("run_statue") != null ? data.getJSONObject("zhengCheShuJu").getString("run_statue") : "";
                vehspeed = data.getJSONObject("zhengCheShuJu").getString("vehspeed") != null ? data.getJSONObject("zhengCheShuJu").getString("vehspeed") : null;
                milleage = data.getJSONObject("zhengCheShuJu").getString("milleage") != null ? data.getJSONObject("zhengCheShuJu").getString("milleage") : "";
                total_voltage = data.getJSONObject("zhengCheShuJu").getString("total_voltage") != null ? data.getJSONObject("zhengCheShuJu").getString("total_voltage") : "";
                total_current = data.getJSONObject("zhengCheShuJu").getString("total_current") != null ? data.getJSONObject("zhengCheShuJu").getString("total_current") : "";
                soc = data.getJSONObject("zhengCheShuJu").getString("soc") != null ? data.getJSONObject("zhengCheShuJu").getString("soc") : "";
                dc_statue = data.getJSONObject("zhengCheShuJu").getString("dc_statue") != null ? data.getJSONObject("zhengCheShuJu").getString("dc_statue") : "";
                gears = data.getJSONObject("zhengCheShuJu").getString("gears") != null ? data.getJSONObject("zhengCheShuJu").getString("gears") : "";
                insulation_resistance = data.getJSONObject("zhengCheShuJu").getString("insulation_resistance") != null ? data.getJSONObject("zhengCheShuJu").getString("insulation_resistance") : "";
                accele_pedal = data.getJSONObject("zhengCheShuJu").getString("accele_pedal") != null ? data.getJSONObject("zhengCheShuJu").getString("accele_pedal") : "";
                brake_paddle = data.getJSONObject("zhengCheShuJu").getString("brake_paddle") != null ? data.getJSONObject("zhengCheShuJu").getString("brake_paddle") : "";
            }

            //car_statue
//            String car_statue = data.getJSONObject("zhengCheShuJu").getString("car_statue") != null ? data.getJSONObject("zhengCheShuJu").getString("car_statue") : "";
            sourcedata.setCar_statue(car_statue);
            //recharge_statue
//            String recharge_statue = data.getJSONObject("zhengCheShuJu").getString("recharge_statue") != null ? data.getJSONObject("zhengCheShuJu").getString("recharge_statue") : "";
            sourcedata.setRecharge_statue(recharge_statue);
            //run_statue
//            String run_statue = data.getJSONObject("zhengCheShuJu").getString("run_statue") != null ? data.getJSONObject("zhengCheShuJu").getString("run_statue") : "";
            sourcedata.setRun_statue(run_statue);
            //vehspeed
//            String vehspeed = data.getJSONObject("zhengCheShuJu").getString("vehspeed") != null ? data.getJSONObject("zhengCheShuJu").getString("vehspeed") : null;
            sourcedata.setVehspeed(vehspeed);
            //milleage
//            String milleage = data.getJSONObject("zhengCheShuJu").getString("milleage") != null ? data.getJSONObject("zhengCheShuJu").getString("milleage") : "";
            sourcedata.setMilleage(milleage);
            //total_voltage
//            String total_voltage = data.getJSONObject("zhengCheShuJu").getString("total_voltage") != null ? data.getJSONObject("zhengCheShuJu").getString("total_voltage") : "";
            sourcedata.setTotal_voltage(total_voltage);
            //total_current
//            String total_current = data.getJSONObject("zhengCheShuJu").getString("total_current") != null ? data.getJSONObject("zhengCheShuJu").getString("total_current") : "";
            sourcedata.setTotal_current(total_current);
            //soc
//            String soc = data.getJSONObject("zhengCheShuJu").getString("soc") != null ? data.getJSONObject("zhengCheShuJu").getString("soc") : "";
            sourcedata.setSoc(soc);
            //dc_statue
//            String dc_statue = data.getJSONObject("zhengCheShuJu").getString("dc_statue") != null ? data.getJSONObject("zhengCheShuJu").getString("dc_statue") : "";
            sourcedata.setDc_statue(dc_statue);
            //gears
//            String gears = data.getJSONObject("zhengCheShuJu").getString("gears") != null ? data.getJSONObject("zhengCheShuJu").getString("gears") : "";
            sourcedata.setGears(gears);
            //insulation_resistance
//            String insulation_resistance = data.getJSONObject("zhengCheShuJu").getString("insulation_resistance") != null ? data.getJSONObject("zhengCheShuJu").getString("insulation_resistance") : "";
            sourcedata.setInsulation_resistance(insulation_resistance);
            //accele_pedal
//            String accele_pedal = data.getJSONObject("zhengCheShuJu").getString("accele_pedal") != null ? data.getJSONObject("zhengCheShuJu").getString("accele_pedal") : "";
            sourcedata.setAccele_pedal(accele_pedal);
            //brake_paddle
//            String brake_paddle = data.getJSONObject("zhengCheShuJu").getString("brake_paddle") != null ? data.getJSONObject("zhengCheShuJu").getString("brake_paddle") : "";
            sourcedata.setBrake_paddle(brake_paddle);
            //drive_motor_control_temp


            String drive_motor_control_temp = "";
            String drive_motor_id = "";
            String drive_motor_speed = "";
            String drive_motor_statu = "";
            String drive_motor_temp = "";
            String drive_motor_torque = "";
            String motor_bus_current = "";
            String motor_input_voltage = "";
            if (data.getJSONObject("quDongDianJiShuJu") != null) {
                drive_motor_control_temp = data.getJSONObject("quDongDianJiShuJu").getString("drive_motor_control_temp") != null ? data.getJSONObject("quDongDianJiShuJu").getString("drive_motor_control_temp") : "";
                drive_motor_id = data.getJSONObject("quDongDianJiShuJu").getString("drive_motor_id") != null ? data.getJSONObject("quDongDianJiShuJu").getString("drive_motor_id") : "";
                drive_motor_speed = data.getJSONObject("quDongDianJiShuJu").getString("drive_motor_speed") != null ? data.getJSONObject("quDongDianJiShuJu").getString("drive_motor_speed") : "";
                drive_motor_statu = data.getJSONObject("quDongDianJiShuJu").getString("drive_motor_statu") != null ? data.getJSONObject("quDongDianJiShuJu").getString("drive_motor_statu") : "";
                drive_motor_temp = data.getJSONObject("quDongDianJiShuJu").getString("drive_motor_temp") != null ? data.getJSONObject("quDongDianJiShuJu").getString("drive_motor_temp") : "";
                drive_motor_torque = data.getJSONObject("quDongDianJiShuJu").getString("drive_motor_torque") != null ? data.getJSONObject("quDongDianJiShuJu").getString("drive_motor_torque") : "";
            }
//        String drive_motor_control_temp = data.getJSONObject("quDongDianJiShuJu").getString("drive_motor_control_temp") != null ? data.getJSONObject("quDongDianJiShuJu").getString("drive_motor_control_temp") : "";
            sourcedata.setDrive_motor_control_temp(drive_motor_control_temp);
            //drive_motor_id
//        String drive_motor_id = data.getJSONObject("quDongDianJiShuJu").getString("drive_motor_id") != null ? data.getJSONObject("quDongDianJiShuJu").getString("drive_motor_id") : "";
            sourcedata.setDrive_motor_id(drive_motor_id);
            //drive_motor_speed
//        String drive_motor_speed = data.getJSONObject("quDongDianJiShuJu").getString("drive_motor_speed") != null ? data.getJSONObject("quDongDianJiShuJu").getString("drive_motor_speed") : "";
            sourcedata.setDrive_motor_speed(drive_motor_speed);

            //drive_motor_statu
//        String drive_motor_statu = data.getJSONObject("quDongDianJiShuJu").getString("drive_motor_statu") != null ? data.getJSONObject("quDongDianJiShuJu").getString("drive_motor_statu") : "";
            sourcedata.setDrive_motor_statu(drive_motor_statu);
            //drive_motor_temp
//        String drive_motor_temp = data.getJSONObject("quDongDianJiShuJu").getString("drive_motor_temp") != null ? data.getJSONObject("quDongDianJiShuJu").getString("drive_motor_temp") : "";
            sourcedata.setDrive_motor_control_temp(drive_motor_temp);
            //drive_motor_torque
//        String drive_motor_torque = data.getJSONObject("quDongDianJiShuJu").getString("drive_motor_torque") != null ? data.getJSONObject("quDongDianJiShuJu").getString("drive_motor_torque") : "";
            sourcedata.setDrive_motor_torque(drive_motor_torque);
            //motor_bus_current
//        String motor_bus_current = data.getJSONObject("quDongDianJiShuJu").getString("motor_bus_current") != null ? data.getJSONObject("quDongDianJiShuJu").getString("motor_bus_current") : "";
            sourcedata.setMotor_bus_current(motor_bus_current);
            //motor_input_voltage
//        String motor_input_voltage = data.getJSONObject("quDongDianJiShuJu").getString("motor_input_voltage") != null ? data.getJSONObject("quDongDianJiShuJu").getString("motor_input_voltage") : "";
            sourcedata.setMotor_input_voltage(motor_input_voltage);

            //注意发动机数据可能为null:
            String engine_status = "";
            String crankshaft_speed = "";
            String fuel_consume = "";
            if (data.getJSONObject("faDongJiShuJu") == null) {
                engine_status = "";
                crankshaft_speed = "";
                fuel_consume = "";
            } else {
                //engine_status
                engine_status = data.getJSONObject("faDongJiShuJu").getString("engine_status") != null ? data.getJSONObject("faDongJiShuJu").getString("engine_status") : "";
                //crankshaft_speed
                crankshaft_speed = data.getJSONObject("faDongJiShuJu").getString("crankshaft_speed") != null ? data.getJSONObject("faDongJiShuJu").getString("crankshaft_speed") : "";
                //fuel_consume
                fuel_consume = data.getJSONObject("faDongJiShuJu").getString("fuel_consume") != null ? data.getJSONObject("faDongJiShuJu").getString("fuel_consume") : "";
            }
            sourcedata.setEngine_status(engine_status);
            sourcedata.setCrankshaft_speed(crankshaft_speed);
            sourcedata.setFuel_consume(fuel_consume);
            //latitude
            String latitude = "";
            String location_status = "";
            String longitude = "";
            if (data.getJSONObject("cheLiangWeiZhiShuJu") != null) {
                latitude = data.getJSONObject("cheLiangWeiZhiShuJu").getString("latitude") != null ? data.getJSONObject("cheLiangWeiZhiShuJu").getString("latitude") : "";
                location_status = data.getJSONObject("cheLiangWeiZhiShuJu").getString("location_status") != null ? data.getJSONObject("cheLiangWeiZhiShuJu").getString("location_status") : "";
                longitude = data.getJSONObject("cheLiangWeiZhiShuJu").getString("longitude") != null ? data.getJSONObject("cheLiangWeiZhiShuJu").getString("longitude") : "";
            }
//        String latitude = data.getJSONObject("cheLiangWeiZhiShuJu").getString("latitude") != null ? data.getJSONObject("cheLiangWeiZhiShuJu").getString("latitude") : "";
            sourcedata.setLatitude(latitude);
            //location_status
//        String location_status = data.getJSONObject("cheLiangWeiZhiShuJu").getString("location_status") != null ? data.getJSONObject("cheLiangWeiZhiShuJu").getString("location_status") : "";
            sourcedata.setLocation_status(location_status);
            //longitude
//        String longitude = data.getJSONObject("cheLiangWeiZhiShuJu").getString("longitude") != null ? data.getJSONObject("cheLiangWeiZhiShuJu").getString("longitude") : "";
            sourcedata.setLongitude(longitude);

            //battery_monomer_max
            String battery_monomer_max = "";
            String battery_monomer_min = "";
            String max_temp = "";
            String max_temp_probeid = "";
            String max_temp_systemid = "";
            String min_temp = "";
            String min_temp_probeid = "";
            String min_temp_systemid = "";
            String voltage_battery_monomerid_max = "";
            String voltage_battery_monomerid_min = "";
            String voltage_battery_systemid_max = "";
            String voltage_battery_systemid_min = "";
            if (data.getJSONObject("jiZhiShuJu") != null) {
                battery_monomer_max = data.getJSONObject("jiZhiShuJu").getString("battery_monomer_max") != null ? data.getJSONObject("jiZhiShuJu").getString("battery_monomer_max") : "";
                battery_monomer_min = data.getJSONObject("jiZhiShuJu").getString("battery_monomer_min") != null ? data.getJSONObject("jiZhiShuJu").getString("battery_monomer_min") : "";
                max_temp = data.getJSONObject("jiZhiShuJu").getString("max_temp") != null ? data.getJSONObject("jiZhiShuJu").getString("max_temp") : "";
                max_temp_probeid = data.getJSONObject("jiZhiShuJu").getString("max_temp_probeid") != null ? data.getJSONObject("jiZhiShuJu").getString("max_temp_probeid") : "";
                max_temp_systemid = data.getJSONObject("jiZhiShuJu").getString("max_temp_systemid") != null ? data.getJSONObject("jiZhiShuJu").getString("max_temp_systemid") : "";
                min_temp = data.getJSONObject("jiZhiShuJu").getString("min_temp") != null ? data.getJSONObject("jiZhiShuJu").getString("min_temp") : "";
                min_temp_probeid = data.getJSONObject("jiZhiShuJu").getString("min_temp_probeid") != null ? data.getJSONObject("jiZhiShuJu").getString("min_temp_probeid") : "";
                min_temp_systemid = data.getJSONObject("jiZhiShuJu").getString("min_temp_systemid") != null ? data.getJSONObject("jiZhiShuJu").getString("min_temp_systemid") : "";
                voltage_battery_monomerid_max = data.getJSONObject("jiZhiShuJu").getString("voltage_battery_monomerid_max") != null ? data.getJSONObject("jiZhiShuJu").getString("voltage_battery_monomerid_max") : "";
                voltage_battery_monomerid_min = data.getJSONObject("jiZhiShuJu").getString("voltage_battery_monomerid_min") != null ? data.getJSONObject("jiZhiShuJu").getString("voltage_battery_monomerid_min") : "";
                voltage_battery_systemid_max = data.getJSONObject("jiZhiShuJu").getString("voltage_battery_systemid_max") != null ? data.getJSONObject("jiZhiShuJu").getString("voltage_battery_systemid_max") : "";
                voltage_battery_systemid_min = data.getJSONObject("jiZhiShuJu").getString("voltage_battery_systemid_min") != null ? data.getJSONObject("jiZhiShuJu").getString("voltage_battery_systemid_min") : "";
            }
//        String battery_monomer_max = data.getJSONObject("jiZhiShuJu").getString("battery_monomer_max") != null ? data.getJSONObject("jiZhiShuJu").getString("battery_monomer_max") : "";
            sourcedata.setBattery_monomer_max(battery_monomer_max);
            //battery_monomer_min
//        String battery_monomer_min = data.getJSONObject("jiZhiShuJu").getString("battery_monomer_min") != null ? data.getJSONObject("jiZhiShuJu").getString("battery_monomer_min") : "";
            sourcedata.setBattery_monomer_min(battery_monomer_min);
            //max_temp
//        String max_temp = data.getJSONObject("jiZhiShuJu").getString("max_temp") != null ? data.getJSONObject("jiZhiShuJu").getString("max_temp") : "";
            sourcedata.setMax_temp(max_temp);
            //max_temp_probeid
//        String max_temp_probeid = data.getJSONObject("jiZhiShuJu").getString("max_temp_probeid") != null ? data.getJSONObject("jiZhiShuJu").getString("max_temp_probeid") : "";
            sourcedata.setMax_temp_probeid(max_temp_probeid);
            //max_temp_systemid
//        String max_temp_systemid = data.getJSONObject("jiZhiShuJu").getString("max_temp_systemid") != null ? data.getJSONObject("jiZhiShuJu").getString("max_temp_systemid") : "";
            sourcedata.setMax_temp_systemid(max_temp_systemid);
            //min_temp
//        String min_temp = data.getJSONObject("jiZhiShuJu").getString("min_temp") != null ? data.getJSONObject("jiZhiShuJu").getString("min_temp") : "";
            sourcedata.setMin_temp(min_temp);
            //min_temp_probeid
//        String min_temp_probeid = data.getJSONObject("jiZhiShuJu").getString("min_temp_probeid") != null ? data.getJSONObject("jiZhiShuJu").getString("min_temp_probeid") : "";
            sourcedata.setMin_temp_probeid(min_temp_probeid);
            //min_temp_systemid
//        String min_temp_systemid = data.getJSONObject("jiZhiShuJu").getString("min_temp_systemid") != null ? data.getJSONObject("jiZhiShuJu").getString("min_temp_systemid") : "";
            sourcedata.setMin_temp_systemid(min_temp_systemid);
            //voltage_battery_monomerid_max
//        String voltage_battery_monomerid_max = data.getJSONObject("jiZhiShuJu").getString("voltage_battery_monomerid_max") != null ? data.getJSONObject("jiZhiShuJu").getString("voltage_battery_monomerid_max") : "";
            sourcedata.setVoltage_battery_monomerid_max(voltage_battery_monomerid_max);
            //voltage_battery_monomerid_min
//        String voltage_battery_monomerid_min = data.getJSONObject("jiZhiShuJu").getString("voltage_battery_monomerid_min") != null ? data.getJSONObject("jiZhiShuJu").getString("voltage_battery_monomerid_min") : "";
            sourcedata.setVoltage_battery_monomerid_min(voltage_battery_monomerid_min);

            //voltage_battery_systemid_max
//        String voltage_battery_systemid_max = data.getJSONObject("jiZhiShuJu").getString("voltage_battery_systemid_max") != null ? data.getJSONObject("jiZhiShuJu").getString("voltage_battery_systemid_max") : "";
            sourcedata.setVoltage_battery_systemid_max(voltage_battery_systemid_max);
            //voltage_battery_systemid_min
//        String voltage_battery_systemid_min = data.getJSONObject("jiZhiShuJu").getString("voltage_battery_systemid_min") != null ? data.getJSONObject("jiZhiShuJu").getString("voltage_battery_systemid_min") : "";
            sourcedata.setVoltage_battery_systemid_min(voltage_battery_systemid_min);
            //battery_cell_lowconsis_alarm

            String battery_cell_lowconsis_alarm = "";
            String battery_cell_overpress_alarm = "";
            String battery_cell_underpress_alarm = "";
            String battery_hightemp_alarm = "";
            String brake_system_alarm = "";
            String common_alarm = "";
            String dc_statu_alarm = "";
            String dc_temp_alarm = "";
            String drive_motor_temp_alarm = "";
            String driver_conttemp_alarm = "";
            String driver_machine_trouble_list = "";
            String driver_machine_trouble_total = "";
            String engine_trouble_list = "";
            String engine_trouble_total = "";
            String high_pressure_interlock_alrm = "";
            String high_soc_alarm = "";
            String insulation_alarm = "";
            String low_soc_alarm = "";
            String max_alarm_level = "";
            String other_trouble_list = "";
            String other_trouble_total = "";
            String recharge_energy = "";
            String recharge_fault_list = "";
            String recharge_fault_total = "";
            String soc_hop_alarm = "";
            String temp_diff_alarm = "";
            String vehicle_mounted_overpress_alarm = "";
            String vehicle_mounted_storahe_overcharge = "";
            String vehicle_mounted_underpress_alarm = "";
            if (data.getJSONObject("baoJingShuJu") != null) {
                battery_cell_lowconsis_alarm = data.getJSONObject("baoJingShuJu").getString("battery_cell_lowconsis_alarm") != null ? data.getJSONObject("baoJingShuJu").getString("battery_cell_lowconsis_alarm") : "";
                battery_cell_overpress_alarm = data.getJSONObject("baoJingShuJu").getString("battery_cell_overpress_alarm") != null ? data.getJSONObject("baoJingShuJu").getString("battery_cell_overpress_alarm") : "";
                battery_cell_underpress_alarm = data.getJSONObject("baoJingShuJu").getString("battery_cell_underpress_alarm") != null ? data.getJSONObject("baoJingShuJu").getString("battery_cell_underpress_alarm") : "";
                battery_hightemp_alarm = data.getJSONObject("baoJingShuJu").getString("battery_hightemp_alarm") != null ? data.getJSONObject("baoJingShuJu").getString("battery_hightemp_alarm") : "";
                brake_system_alarm = data.getJSONObject("baoJingShuJu").getString("brake_system_alarm") != null ? data.getJSONObject("baoJingShuJu").getString("brake_system_alarm") : "";
                common_alarm = data.getJSONObject("baoJingShuJu").getString("common_alarm") != null ? data.getJSONObject("baoJingShuJu").getString("common_alarm") : "";
                dc_statu_alarm = data.getJSONObject("baoJingShuJu").getString("dc_statu_alarm") != null ? data.getJSONObject("baoJingShuJu").getString("dc_statu_alarm") : "";
                dc_temp_alarm = data.getJSONObject("baoJingShuJu").getString("dc_temp_alarm") != null ? data.getJSONObject("baoJingShuJu").getString("dc_temp_alarm") : "";
                drive_motor_temp_alarm = data.getJSONObject("baoJingShuJu").getString("drive_motor_temp_alarm") != null ? data.getJSONObject("baoJingShuJu").getString("drive_motor_temp_alarm") : "";
                driver_conttemp_alarm = data.getJSONObject("baoJingShuJu").getString("driver_conttemp_alarm") != null ? data.getJSONObject("baoJingShuJu").getString("driver_conttemp_alarm") : "";
                driver_machine_trouble_list = data.getJSONObject("baoJingShuJu").getString("driver_machine_trouble_list") != null ? data.getJSONObject("baoJingShuJu").getString("driver_machine_trouble_list") : "";
                driver_machine_trouble_total = data.getJSONObject("baoJingShuJu").getString("driver_machine_trouble_total") != null ? data.getJSONObject("baoJingShuJu").getString("driver_machine_trouble_total") : "";
                engine_trouble_list = data.getJSONObject("baoJingShuJu").getString("engine_trouble_list") != null ? data.getJSONObject("baoJingShuJu").getString("engine_trouble_list") : "";
                engine_trouble_total = data.getJSONObject("baoJingShuJu").getString("engine_trouble_total") != null ? data.getJSONObject("baoJingShuJu").getString("engine_trouble_total") : "";
                high_pressure_interlock_alrm = data.getJSONObject("baoJingShuJu").getString("high_pressure_interlock_alrm") != null ? data.getJSONObject("baoJingShuJu").getString("high_pressure_interlock_alrm") : "";
                insulation_alarm = data.getJSONObject("baoJingShuJu").getString("insulation_alarm") != null ? data.getJSONObject("baoJingShuJu").getString("insulation_alarm") : "";
                low_soc_alarm = data.getJSONObject("baoJingShuJu").getString("low_soc_alarm") != null ? data.getJSONObject("baoJingShuJu").getString("low_soc_alarm") : "";
                max_alarm_level = data.getJSONObject("baoJingShuJu").getString("max_alarm_level") != null ? data.getJSONObject("baoJingShuJu").getString("max_alarm_level") : "";
                other_trouble_list = data.getJSONObject("baoJingShuJu").getString("other_trouble_list") != null ? data.getJSONObject("baoJingShuJu").getString("other_trouble_list") : "";
                other_trouble_total = data.getJSONObject("baoJingShuJu").getString("other_trouble_total") != null ? data.getJSONObject("baoJingShuJu").getString("other_trouble_total") : "";
                recharge_energy = data.getJSONObject("baoJingShuJu").getString("recharge_energy") != null ? data.getJSONObject("baoJingShuJu").getString("recharge_energy") : "";
                recharge_fault_list = data.getJSONObject("baoJingShuJu").getString("recharge_fault_list") != null ? data.getJSONObject("baoJingShuJu").getString("recharge_fault_list") : "";
                recharge_fault_total = data.getJSONObject("baoJingShuJu").getString("recharge_fault_total") != null ? data.getJSONObject("baoJingShuJu").getString("recharge_fault_total") : "";
                soc_hop_alarm = data.getJSONObject("baoJingShuJu").getString("soc_hop_alarm") != null ? data.getJSONObject("baoJingShuJu").getString("soc_hop_alarm") : "";
                temp_diff_alarm = data.getJSONObject("baoJingShuJu").getString("temp_diff_alarm") != null ? data.getJSONObject("baoJingShuJu").getString("temp_diff_alarm") : "";
                vehicle_mounted_overpress_alarm = data.getJSONObject("baoJingShuJu").getString("vehicle_mounted_overpress_alarm") != null ? data.getJSONObject("baoJingShuJu").getString("vehicle_mounted_overpress_alarm") : "";
                vehicle_mounted_storahe_overcharge = data.getJSONObject("baoJingShuJu").getString("vehicle_mounted_storahe_overcharge") != null ? data.getJSONObject("baoJingShuJu").getString("vehicle_mounted_storahe_overcharge") : "";
                vehicle_mounted_underpress_alarm = data.getJSONObject("baoJingShuJu").getString("vehicle_mounted_underpress_alarm") != null ? data.getJSONObject("baoJingShuJu").getString("vehicle_mounted_underpress_alarm") : "";


            }
//        String battery_cell_lowconsis_alarm = data.getJSONObject("baoJingShuJu").getString("battery_cell_lowconsis_alarm") != null ? data.getJSONObject("baoJingShuJu").getString("battery_cell_lowconsis_alarm") : "";
            sourcedata.setBattery_cell_lowconsis_alarm(battery_cell_lowconsis_alarm);
            // jsonObject.put("battery_cell_lowconsis_alarm",battery_cell_lowconsis_alarm);

            //battery_cell_overpress_alarm
//        String battery_cell_overpress_alarm = data.getJSONObject("baoJingShuJu").getString("battery_cell_overpress_alarm") != null ? data.getJSONObject("baoJingShuJu").getString("battery_cell_overpress_alarm") : "";
            sourcedata.setBattery_cell_overpress_alarm(battery_cell_overpress_alarm);
//        jsonObject.put("battery_cell_overpress_alarm",battery_cell_overpress_alarm);


            //battery_cell_underpress_alarm
//        String battery_cell_underpress_alarm = data.getJSONObject("baoJingShuJu").getString("battery_cell_underpress_alarm") != null ? data.getJSONObject("baoJingShuJu").getString("battery_cell_underpress_alarm") : "";
            sourcedata.setBattery_cell_underpress_alarm(battery_cell_underpress_alarm);
//        jsonObject.put("battery_cell_underpress_alarm",battery_cell_underpress_alarm);


            //battery_hightemp_alarm
//        String battery_hightemp_alarm = data.getJSONObject("baoJingShuJu").getString("battery_hightemp_alarm") != null ? data.getJSONObject("baoJingShuJu").getString("battery_hightemp_alarm") : "";
            sourcedata.setBattery_hightemp_alarm(battery_hightemp_alarm);
//        jsonObject.put("battery_hightemp_alarm",battery_hightemp_alarm);


            //brake_system_alarm
//        String brake_system_alarm = data.getJSONObject("baoJingShuJu").getString("brake_system_alarm") != null ? data.getJSONObject("baoJingShuJu").getString("brake_system_alarm") : "";
            sourcedata.setBrake_system_alarm(brake_system_alarm);
//        jsonObject.put("brake_system_alarm",brake_system_alarm);


            //common_alarm
//        String common_alarm = data.getJSONObject("baoJingShuJu").getString("common_alarm") != null ? data.getJSONObject("baoJingShuJu").getString("common_alarm") : "";
            sourcedata.setCommon_alarm(common_alarm);
//        jsonObject.put("common_alarm",common_alarm);


            //dc_statu_alarm
//        String dc_statu_alarm = data.getJSONObject("baoJingShuJu").getString("dc_statu_alarm") != null ? data.getJSONObject("baoJingShuJu").getString("dc_statu_alarm") : "";
            sourcedata.setDc_statu_alarm(dc_statu_alarm);
//        jsonObject.put("dc_statu_alarm",dc_statu_alarm);


            //dc_temp_alarm
//        String dc_temp_alarm = data.getJSONObject("baoJingShuJu").getString("dc_temp_alarm") != null ? data.getJSONObject("baoJingShuJu").getString("dc_temp_alarm") : "";
            sourcedata.setDc_temp_alarm(dc_temp_alarm);
//        jsonObject.put("dc_temp_alarm",dc_temp_alarm);


            //drive_motor_temp_alarm
//        String drive_motor_temp_alarm = data.getJSONObject("baoJingShuJu").getString("drive_motor_temp_alarm") != null ? data.getJSONObject("baoJingShuJu").getString("drive_motor_temp_alarm") : "";
            sourcedata.setDrive_motor_temp_alarm(drive_motor_temp_alarm);
//        jsonObject.put("drive_motor_temp_alarm",drive_motor_temp_alarm);


            //driver_conttemp_alarm
//        String driver_conttemp_alarm = data.getJSONObject("baoJingShuJu").getString("driver_conttemp_alarm") != null ? data.getJSONObject("baoJingShuJu").getString("driver_conttemp_alarm") : "";
            sourcedata.setDriver_conttemp_alarm(driver_conttemp_alarm);
//        jsonObject.put("driver_conttemp_alarm",driver_conttemp_alarm);


            //driver_machine_trouble_list
//        String driver_machine_trouble_list = data.getJSONObject("baoJingShuJu").getString("driver_machine_trouble_list") != null ? data.getJSONObject("baoJingShuJu").getString("driver_machine_trouble_list") : "";
            sourcedata.setDriver_machine_trouble_list(driver_machine_trouble_list);
//        jsonObject.put("driver_machine_trouble_list",driver_machine_trouble_list);


            //driver_machine_trouble_total
//        String driver_machine_trouble_total = data.getJSONObject("baoJingShuJu").getString("driver_machine_trouble_total") != null ? data.getJSONObject("baoJingShuJu").getString("driver_machine_trouble_total") : "";
            sourcedata.setDriver_machine_trouble_total(driver_machine_trouble_total);
//        jsonObject.put("driver_machine_trouble_total",driver_machine_trouble_total);


            //engine_trouble_list
//        String engine_trouble_list = data.getJSONObject("baoJingShuJu").getString("engine_trouble_list") != null ? data.getJSONObject("baoJingShuJu").getString("engine_trouble_list") : "";
            sourcedata.setEngine_trouble_list(engine_trouble_list);
//        jsonObject.put("engine_trouble_list",engine_trouble_list);


            //engine_trouble_total
//        String engine_trouble_total = data.getJSONObject("baoJingShuJu").getString("engine_trouble_total") != null ? data.getJSONObject("baoJingShuJu").getString("engine_trouble_total") : "";
            sourcedata.setEngine_trouble_total(engine_trouble_total);
//        jsonObject.put("engine_trouble_total",engine_trouble_total);


            //high_pressure_interlock_alrm
//        String high_pressure_interlock_alrm = data.getJSONObject("baoJingShuJu").getString("high_pressure_interlock_alrm") != null ? data.getJSONObject("baoJingShuJu").getString("high_pressure_interlock_alrm") : "";
            sourcedata.setHigh_pressure_interlock_alrm(high_pressure_interlock_alrm);
//        jsonObject.put("high_pressure_interlock_alrm",high_pressure_interlock_alrm);


            //high_soc_alarm
//        String high_soc_alarm = data.getJSONObject("baoJingShuJu").getString("high_soc_alarm") != null ? data.getJSONObject("baoJingShuJu").getString("high_soc_alarm") : "";
            sourcedata.setHigh_soc_alarm(high_soc_alarm);
//        jsonObject.put("high_soc_alarm",high_soc_alarm);


            //insulation_alarm
//        String insulation_alarm = data.getJSONObject("baoJingShuJu").getString("insulation_alarm") != null ? data.getJSONObject("baoJingShuJu").getString("insulation_alarm") : "";
            sourcedata.setInsulation_alarm(insulation_alarm);
//        jsonObject.put("insulation_alarm",insulation_alarm);


            //low_soc_alarm
//        String low_soc_alarm = data.getJSONObject("baoJingShuJu").getString("low_soc_alarm") != null ? data.getJSONObject("baoJingShuJu").getString("low_soc_alarm") : "";
            sourcedata.setLow_soc_alarm(low_soc_alarm);
//        jsonObject.put("low_soc_alarm",low_soc_alarm);

            //max_alarm_level
//        String max_alarm_level = data.getJSONObject("baoJingShuJu").getString("max_alarm_level") != null ? data.getJSONObject("baoJingShuJu").getString("max_alarm_level") : "";
            sourcedata.setMax_alarm_level(max_alarm_level);
//        jsonObject.put("max_alarm_level",max_alarm_level);


            //other_trouble_list
//        String other_trouble_list = data.getJSONObject("baoJingShuJu").getString("other_trouble_list") != null ? data.getJSONObject("baoJingShuJu").getString("other_trouble_list") : "";
            sourcedata.setOther_trouble_list(other_trouble_list);
//        jsonObject.put("other_trouble_list",other_trouble_list);


            //other_trouble_total
//        String other_trouble_total = data.getJSONObject("baoJingShuJu").getString("other_trouble_total") != null ? data.getJSONObject("baoJingShuJu").getString("other_trouble_total") : "";
            sourcedata.setOther_trouble_total(other_trouble_total);
//        jsonObject.put("other_trouble_total",other_trouble_total);


            //recharge_energy
//        String recharge_energy = data.getJSONObject("baoJingShuJu").getString("recharge_energy") != null ? data.getJSONObject("baoJingShuJu").getString("recharge_energy") : "";
            sourcedata.setRecharge_energy(recharge_energy);
//        jsonObject.put("recharge_energy",recharge_energy);


            //recharge_fault_list
//        String recharge_fault_list = data.getJSONObject("baoJingShuJu").getString("recharge_fault_list") != null ? data.getJSONObject("baoJingShuJu").getString("recharge_fault_list") : "";
            sourcedata.setRecharge_fault_list(recharge_fault_list);
//        jsonObject.put("recharge_fault_list",recharge_fault_list);


            //recharge_fault_total
//        String recharge_fault_total = data.getJSONObject("baoJingShuJu").getString("recharge_fault_total") != null ? data.getJSONObject("baoJingShuJu").getString("recharge_fault_total") : "";
            sourcedata.setRecharge_fault_total(recharge_fault_total);
//        jsonObject.put("recharge_fault_total",recharge_fault_total);


            //soc_hop_alarm
//        String soc_hop_alarm = data.getJSONObject("baoJingShuJu").getString("soc_hop_alarm") != null ? data.getJSONObject("baoJingShuJu").getString("soc_hop_alarm") : "";
            sourcedata.setSoc_hop_alarm(soc_hop_alarm);
//        jsonObject.put("soc_hop_alarm",soc_hop_alarm);

            //temp_diff_alarm
//        String temp_diff_alarm = data.getJSONObject("baoJingShuJu").getString("temp_diff_alarm") != null ? data.getJSONObject("baoJingShuJu").getString("temp_diff_alarm") : "";
            sourcedata.setTemp_diff_alarm(temp_diff_alarm);
//        jsonObject.put("temp_diff_alarm",temp_diff_alarm);


            //vehicle_mounted_overpress_alarm
//        String vehicle_mounted_overpress_alarm = data.getJSONObject("baoJingShuJu").getString("vehicle_mounted_overpress_alarm") != null ? data.getJSONObject("baoJingShuJu").getString("vehicle_mounted_overpress_alarm") : "";
            sourcedata.setVehicle_mounted_overpress_alarm(vehicle_mounted_overpress_alarm);
//        jsonObject.put("vehicle_mounted_overpress_alarm",vehicle_mounted_overpress_alarm);


            //vehicle_mounted_storahe_overcharge
//        String vehicle_mounted_storahe_overcharge = data.getJSONObject("baoJingShuJu").getString("vehicle_mounted_storahe_overcharge") != null ? data.getJSONObject("baoJingShuJu").getString("vehicle_mounted_storahe_overcharge") : "";
            sourcedata.setVehicle_mounted_storahe_overcharge(vehicle_mounted_storahe_overcharge);
//        jsonObject.put("vehicle_mounted_storahe_overcharge",vehicle_mounted_storahe_overcharge);

            //vehicle_mounted_underpress_alarm
//        String vehicle_mounted_underpress_alarm = data.getJSONObject("baoJingShuJu").getString("vehicle_mounted_underpress_alarm") != null ? data.getJSONObject("baoJingShuJu").getString("vehicle_mounted_underpress_alarm") : "";
            sourcedata.setVehicle_mounted_underpress_alarm(vehicle_mounted_underpress_alarm);
//        jsonObject.put("vehicle_mounted_underpress_alarm",vehicle_mounted_underpress_alarm);


            //battery_cell_total
            String battery_cell_total = "";
            String battery_cell_voltage = "";
            String recharge_storage_current = "";
            String recharge_storage_voltage = "";
            String start_battery_cell = "";
            String start_battery_id = "";
            String systemid = "";
            if (data.getJSONObject("dianYaShuJu") != null) {
                battery_cell_total = data.getJSONObject("dianYaShuJu").getString("battery_cell_total") != null ? data.getJSONObject("dianYaShuJu").getString("battery_cell_total") : "";
                battery_cell_voltage = data.getJSONObject("dianYaShuJu").getString("battery_cell_voltage") != null ? data.getJSONObject("dianYaShuJu").getString("battery_cell_voltage") : "";
                recharge_storage_current = data.getJSONObject("dianYaShuJu").getString("recharge_storage_current") != null ? data.getJSONObject("dianYaShuJu").getString("recharge_storage_current") : "";
                recharge_storage_voltage = data.getJSONObject("dianYaShuJu").getString("recharge_storage_voltage") != null ? data.getJSONObject("dianYaShuJu").getString("recharge_storage_voltage") : "";
                start_battery_cell = data.getJSONObject("dianYaShuJu").getString("start_battery_cell") != null ? data.getJSONObject("dianYaShuJu").getString("start_battery_cell") : "";
                start_battery_id = data.getJSONObject("dianYaShuJu").getString("start_battery_id") != null ? data.getJSONObject("dianYaShuJu").getString("start_battery_id") : "";
                systemid = data.getJSONObject("dianYaShuJu").getString("systemid") != null ? data.getJSONObject("dianYaShuJu").getString("systemid") : "";

            }
//        String battery_cell_total = data.getJSONObject("dianYaShuJu").getString("battery_cell_total") != null ? data.getJSONObject("dianYaShuJu").getString("battery_cell_total") : "";
            sourcedata.setBattery_cell_total(battery_cell_total);
//        jsonObject.put("battery_cell_total",battery_cell_total);

            //battery_cell_voltage
//        String battery_cell_voltage = data.getJSONObject("dianYaShuJu").getString("battery_cell_voltage") != null ? data.getJSONObject("dianYaShuJu").getString("battery_cell_voltage") : "";
            sourcedata.setBattery_cell_voltage(battery_cell_voltage);
            //        jsonObject.put("battery_cell_voltage",battery_cell_voltage);

            //recharge_storage_current
//        String recharge_storage_current = data.getJSONObject("dianYaShuJu").getString("recharge_storage_current") != null ? data.getJSONObject("dianYaShuJu").getString("recharge_storage_current") : "";
            sourcedata.setRecharge_storage_current(recharge_storage_current);
            //        jsonObject.put("recharge_storage_current",recharge_storage_current);

            //recharge_storage_voltage
//        String recharge_storage_voltage = data.getJSONObject("dianYaShuJu").getString("recharge_storage_voltage") != null ? data.getJSONObject("dianYaShuJu").getString("recharge_storage_voltage") : "";
            sourcedata.setRecharge_storage_voltage(recharge_storage_voltage);
            //        jsonObject.put("recharge_storage_voltage",recharge_storage_voltage);

            //start_battery_cell
//        String start_battery_cell = data.getJSONObject("dianYaShuJu").getString("start_battery_cell") != null ? data.getJSONObject("dianYaShuJu").getString("start_battery_cell") : "";
            sourcedata.setStart_battery_cell(start_battery_cell);
            //        jsonObject.put("start_battery_cell",start_battery_cell);

            //start_battery_id
//        String start_battery_id = data.getJSONObject("dianYaShuJu").getString("start_battery_id") != null ? data.getJSONObject("dianYaShuJu").getString("start_battery_id") : "";
            sourcedata.setStart_battery_id(start_battery_id);

            //        jsonObject.put("start_battery_id",start_battery_id);
            //systemid

//        String systemid = data.getJSONObject("dianYaShuJu").getString("systemid") != null ? data.getJSONObject("dianYaShuJu").getString("systemid") : "";
            sourcedata.setSystemid(systemid);
        /*        jsonObject.put("systemid",systemid);
        sourcedata.setJson_str(jsonObject.toString());*/

            String year = gatherTime.substring(0, 4);
            sourcedata.setYears(year);
            String month = gatherTime.substring(5, 7);
            sourcedata.setMonths(month);
            String day = gatherTime.substring(0, 4) + gatherTime.substring(5, 7) + gatherTime.substring(8, 10);
            sourcedata.setDays(day);

        }
        return sourcedata;
    }

    public static GpsData getArea(String message) throws Exception {
        JSONObject data = JSON.parseObject(message);

        System.out.println("开始处理数据。。。");
        GpsData gpsdata = new GpsData();

        if ((message != null) || (!message.equals(""))) {
            //vin
            String vin = data.getString("vin") != null ? data.getString("vin") : "";
            gpsdata.setVin(vin.toString());
            //gpss_time
            String gatherTime = data.getString("gatherTime") != null ? data.getString("gatherTime") : "";
            gpsdata.setGps_time(gatherTime);
            String milleage ="";
            String soc ="";
            if (data.getJSONObject("zhengCheShuJu") != null) {
                milleage = data.getJSONObject("zhengCheShuJu").getString("milleage") != null ? data.getJSONObject("zhengCheShuJu").getString("milleage") : "";
                soc = data.getJSONObject("zhengCheShuJu").getString("soc") != null ? data.getJSONObject("zhengCheShuJu").getString("soc") : "";
            }
            gpsdata.setMilleage(milleage);
            gpsdata.setSoc(soc);
            String latitude = "";
            String longitude = "";
            if (data.getJSONObject("cheLiangWeiZhiShuJu") != null) {
                latitude = data.getJSONObject("cheLiangWeiZhiShuJu").getString("latitude") != null ? data.getJSONObject("cheLiangWeiZhiShuJu").getString("latitude") : "";
                longitude = data.getJSONObject("cheLiangWeiZhiShuJu").getString("longitude") != null ? data.getJSONObject("cheLiangWeiZhiShuJu").getString("longitude") : "";
            }
            gpsdata.setLatitude(latitude);
            gpsdata.setLongitude(longitude);


        }
        return gpsdata;
    }
}
